<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">
        <input type="text" id="text">
    </div>
    <script>
        const text = document.getElementById('text')
        const box = document.getElementById('box')
        // 捕获（true）：从启动事件的元素节点开始，逐层往下传递（类似向下捕获东西）
        // 冒泡（false）：逐层向上依序被触发（类似浮起来的气泡）
        text.addEventListener('click', function() {
            console.log('input clicked')
        }, true);
        box.addEventListener('click', function() {
            console.log('box clicked')
        }, false);
        // text.onclick = function(e) {
        //     console.log('onclick')
        // }
        text.onfocus = function(e) {
            console.log('onfocus')
        }
        text.onmousedown = function(e) {
            console.log('onmousedown')
        }
        text.onmouseenter = function(e) {
            console.log('onmouseenter')
        }
    </script>
</body>
</html>